import java.io.File;
import java.io.IOException;

public class Demo1 {
    public static void main(String[] args) throws IOException {
        String filePath = "./Test/test";
        File file = new File(filePath);
        System.out.println(file.getParentFile());
        System.out.println(file.getName());
        System.out.println(file.getPath());
        System.out.println(file.getAbsolutePath());
        System.out.println(file.getCanonicalFile());
    }

    public static void main2(String[] args) throws IOException {
        String parentPath = "D:/Test";
        String childPath = "test";

        //此文件还未创建
        File file = new File(parentPath, childPath);

        System.out.println(file.exists());
        System.out.println(file.isDirectory());
        System.out.println(file.isFile());

        System.out.println(file.createNewFile());
        System.out.println(file.exists());
        System.out.println(file.isDirectory());
        System.out.println(file.isFile());

        System.out.println(file.createNewFile());
    }

    public static void main3(String[] args) throws IOException {
        File parentFile = new File("D:/Test");
        String child = "test";
        File file = new File(parentFile, child);
        System.out.println(file.exists());
        System.out.println(file.createNewFile());
        System.out.println(file.exists());
        System.out.println(file.delete());
        System.out.println(file.exists());
    }

    public static void main4(String[] args) {
        File file = new File("D:/Test/test");
        System.out.println(file.isDirectory());
        System.out.println(file.isFile());
        System.out.println(file.mkdir());
        System.out.println(file.isDirectory());
        System.out.println(file.isFile());
    }
}
